home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mscheap2 / heapdbg.h < prev    next >
C/C++ Source or Header  |  1990-03-11  |  10KB  |  255 lines

  1. /*/
  2.        Copyright (c) 1990 by Optimal Software, All Rights Reserved
  3. /*/
  4.  
  5. #if !defined( HEAPDBG_H )
  6.  
  7. #define HEAPDBG_H
  8.  
  9. #if !defined( FILE )
  10.    #include <stdio.h>
  11. #endif
  12.  
  13. /********** Function prototypes and aliases **********/
  14.  
  15. #define DBG_ARGS char near *file, uint line, FILE *stream
  16.  
  17. extern void      *cdecl calloc_d( size_t nitems, size_t nbytes, DBG_ARGS );
  18. extern void      *cdecl calloc_t( size_t nitems, size_t nbytes, DBG_ARGS );
  19.  
  20. extern void      *cdecl _expand_d( void *ptr, size_t nbytes, DBG_ARGS );
  21. extern void      *cdecl _expand_t( void *ptr, size_t nbytes, DBG_ARGS );
  22.  
  23. extern void far  *cdecl _fcalloc_d( size_t nitems, size_t nbytes, DBG_ARGS );
  24. extern void far  *cdecl _fcalloc_t( size_t nitems, size_t nbytes, DBG_ARGS );
  25.  
  26. extern void far  *cdecl _fexpand_d( void far *ptr, size_t nbytes, DBG_ARGS );
  27. extern void far  *cdecl _fexpand_t( void far *ptr, size_t nbytes, DBG_ARGS );
  28.  
  29. extern void       cdecl _ffree_d( void far *ptr, DBG_ARGS );
  30. extern void       cdecl _ffree_t( void far *ptr, DBG_ARGS );
  31.  
  32. extern int        cdecl _fheappack_d( DBG_ARGS );
  33. extern int        cdecl _fheappack_t( DBG_ARGS );
  34.  
  35. extern void far  *cdecl _fmalloc_d( size_t nbytes, DBG_ARGS );
  36. extern void far  *cdecl _fmalloc_t( size_t nbytes, DBG_ARGS );
  37.  
  38. extern void far  *cdecl _frealloc_d( void far *ptr, size_t nbytes, DBG_ARGS );
  39. extern void far  *cdecl _frealloc_t( void far *ptr, size_t nbytes, DBG_ARGS );
  40.  
  41. extern void       cdecl free_d( void *ptr, DBG_ARGS );
  42. extern void       cdecl free_t( void *ptr, DBG_ARGS );
  43.  
  44. extern void far  *cdecl _frelocate_d( void far *ptr, DBG_ARGS );
  45. extern void far  *cdecl _frelocate_t( void far *ptr, DBG_ARGS );
  46.  
  47. extern void huge *cdecl _hcalloc_d( long nitems, size_t nbytes, DBG_ARGS );
  48. extern void huge *cdecl _hcalloc_t( long nitems, size_t nbytes, DBG_ARGS );
  49.  
  50. extern int        cdecl _heappack_d( DBG_ARGS );
  51. extern int        cdecl _heappack_t( DBG_ARGS );
  52.  
  53. extern void huge *cdecl _hexpand_d( void huge *ptr, long nbytes, DBG_ARGS );
  54. extern void huge *cdecl _hexpand_t( void huge *ptr, long nbytes, DBG_ARGS );
  55.  
  56. extern void       cdecl _hfree_d( void huge *ptr, DBG_ARGS );
  57. extern void       cdecl _hfree_t( void huge *ptr, DBG_ARGS );
  58.  
  59. extern int        cdecl _hheappack_d( DBG_ARGS );
  60. extern int        cdecl _hheappack_t( DBG_ARGS );
  61.  
  62. extern void huge *cdecl _hmalloc_d( long nbytes, DBG_ARGS );
  63. extern void huge *cdecl _hmalloc_t( long nbytes, DBG_ARGS );
  64.  
  65. extern void huge *cdecl _hrealloc_d( void huge *ptr, long nbytes, DBG_ARGS );
  66. extern void huge *cdecl _hrealloc_t( void huge *ptr, long nbytes, DBG_ARGS );
  67.  
  68. extern void huge *cdecl _hrelocate_d( void huge *ptr, DBG_ARGS );
  69. extern void huge *cdecl _hrelocate_t( void huge *ptr, DBG_ARGS );
  70.  
  71. extern void      *cdecl malloc_d( size_t nbytes, DBG_ARGS );
  72. extern void      *cdecl malloc_t( size_t nbytes, DBG_ARGS );
  73.  
  74. extern void near *cdecl _ncalloc_d( size_t nitems, size_t nbytes, DBG_ARGS );
  75. extern void near *cdecl _ncalloc_t( size_t nitems, size_t nbytes, DBG_ARGS );
  76.  
  77. extern void near *cdecl _nexpand_d( void near *ptr, size_t nbytes, DBG_ARGS );
  78. extern void near *cdecl _nexpand_t( void near *ptr, size_t nbytes, DBG_ARGS );
  79.  
  80. extern void       cdecl _nfree_d( void near *ptr, DBG_ARGS );
  81. extern void       cdecl _nfree_t( void near *ptr, DBG_ARGS );
  82.  
  83. extern int        cdecl _nheappack_d( DBG_ARGS );
  84. extern int        cdecl _nheappack_t( DBG_ARGS );
  85.  
  86. extern void near *cdecl _nmalloc_d( size_t nbytes, DBG_ARGS );
  87. extern void near *cdecl _nmalloc_t( size_t nbytes, DBG_ARGS );
  88.  
  89. extern void near *cdecl _nrealloc_d( void near *ptr, size_t nbytes, DBG_ARGS );
  90. extern void near *cdecl _nrealloc_t( void near *ptr, size_t nbytes, DBG_ARGS );
  91.  
  92. extern void near *cdecl _nrelocate_d( void near *ptr, DBG_ARGS );
  93. extern void near *cdecl _nrelocate_t( void near *ptr, DBG_ARGS );
  94.  
  95. extern void      *cdecl realloc_d( void *ptr, size_t nbytes, DBG_ARGS );
  96. extern void      *cdecl realloc_t( void *ptr, size_t nbytes, DBG_ARGS );
  97.  
  98. extern void      *cdecl _relocate_d( void *ptr, DBG_ARGS );
  99. extern void      *cdecl _relocate_t( void *ptr, DBG_ARGS );
  100.  
  101. /*/
  102.       Redefine functions to activate debugging, and tracing
  103. /*/
  104.  
  105. #if defined( _HEAPTRACE )
  106.  
  107.    #if defined( MSC )
  108.       #pragma comment ( user, "Compiled with -D_HEAPTRACE -- heap tracing enabled" )
  109.    #endif
  110.  
  111.    #define DBG_VALUES __FILE__, __LINE__, _HEAPTRACE
  112.  
  113.    /*/
  114.          Tracing aliases: xxxxx() becomes xxxxx_t()
  115.    
  116.          Any function that changes the heap must first check for errors,
  117.          and any function that allocates a heap entry must record the salient
  118.          info for heap traceback.
  119.    
  120.          These functions also announce their parameters and results
  121.    /*/
  122.  
  123.    #define calloc( nitems, nbytes )    calloc_t( nitems, nbytes, DBG_VALUES )
  124.  
  125.    #define _expand( ptr, nbytes )      _expand_t( ptr, nbytes, DBG_VALUES )
  126.  
  127.    #define _fcalloc( nitems, nbytes )  _fcalloc_t( nitems, nbytes, DBG_VALUES )
  128.  
  129.    #define _fexpand( ptr, nbytes )     _fexpand_t( ptr, nbytes, DBG_VALUES )
  130.  
  131.    #define _ffree( ptr )               _ffree_t( ptr, DBG_VALUES )
  132.  
  133.    #define _fheappack()                _fheappack_t( DBG_VALUES )
  134.  
  135.    #define _fmalloc( nbytes )          _fmalloc_t( nbytes, DBG_VALUES )
  136.  
  137.    #define _frealloc( ptr, nbytes )    _frealloc_t( ptr, nbytes, DBG_VALUES )
  138.  
  139.    #define free( ptr )                 free_t( ptr, DBG_VALUES )
  140.  
  141.    #define _frelocate( ptr )           _frelocate_t( ptr, DBG_VALUES )
  142.  
  143.    #define _hcalloc( nitems, nbytes )  _hcalloc_t( nitems, nbytes, DBG_VALUES )
  144.  
  145.    #define _heappack()                 _heappack_t( DBG_VALUES )
  146.  
  147.    #define _hexpand( ptr, nbytes )     _hexpand_t( ptr, nbytes, DBG_VALUES )
  148.  
  149.    #define _hfree( ptr )               _hfree_t( ptr, DBG_VALUES )
  150.  
  151.    #define _hheappack()                _hheappack_t( DBG_VALUES )
  152.  
  153.    #define _hmalloc( nbytes )          _hmalloc_t( nbytes, DBG_VALUES )
  154.  
  155.    #define _hrealloc( ptr, nbytes )    _hrealloc_t( ptr, nbytes, DBG_VALUES )
  156.  
  157.    #define _hrelocate( ptr )           _hrelocate_t( ptr, DBG_VALUES )
  158.  
  159.    #define malloc( nbytes )            malloc_t( nbytes, DBG_VALUES )
  160.  
  161.    #define _ncalloc( nitems, nbytes )  _ncalloc_t( nitems, nbytes, DBG_VALUES )
  162.  
  163.    #define _nexpand( ptr, nbytes )     _nexpand_t( ptr, nbytes, DBG_VALUES )
  164.  
  165.    #define _nfree( ptr )               _nfree_t( ptr, DBG_VALUES )
  166.  
  167.    #define _nheappack()                _nheappack_t( DBG_VALUES )
  168.  
  169.    #define _nmalloc( nbytes )          _nmalloc_t( nbytes, DBG_VALUES )
  170.  
  171.    #define _nrealloc( ptr, nbytes )    _nrealloc_t( ptr, nbytes, DBG_VALUES )
  172.  
  173.    #define _nrelocate( ptr )           _nrelocate_t( ptr, DBG_VALUES )
  174.  
  175.    #define realloc( ptr, nbytes )      realloc_t( ptr, nbytes, DBG_VALUES )
  176.  
  177.    #define _relocate( ptr )            _relocate_t( ptr, DBG_VALUES )
  178.  
  179. #elif defined( _HEAPDEBUG )
  180.  
  181.    #if defined( MSC )
  182.       #pragma comment ( user, "Compiled with -D_HEAPDEBUG -- heap debugging enabled" )
  183.    #endif
  184.  
  185.    #define DBG_VALUES __FILE__, __LINE__, _HEAPDEBUG
  186.  
  187.    /*/
  188.          Debugging aliases: xxxxx() becomes xxxxx_d()
  189.    
  190.          Any function that changes the heap must first check for errors,
  191.          and any function that allocates a heap entry must record the salient
  192.          info for heap traceback.
  193.    /*/
  194.  
  195.    #define calloc( nitems, nbytes )    calloc_d( nitems, nbytes, DBG_VALUES )
  196.  
  197.    #define _expand( ptr, nbytes )      _expand_d( ptr, nbytes, DBG_VALUES )
  198.  
  199.    #define _fcalloc( nitems, nbytes )  _fcalloc_d( nitems, nbytes, DBG_VALUES )
  200.  
  201.    #define _fexpand( ptr, nbytes )     _fexpand_d( ptr, nbytes, DBG_VALUES )
  202.  
  203.    #define _ffree( ptr )               _ffree_d( ptr, DBG_VALUES )
  204.  
  205.    #define _fheappack()                _fheappack_d( DBG_VALUES )
  206.  
  207.    #define _fmalloc( nbytes )          _fmalloc_d( nbytes, DBG_VALUES )
  208.  
  209.    #define _frealloc( ptr, nbytes )    _frealloc_d( ptr, nbytes, DBG_VALUES )
  210.  
  211.    #define free( ptr )                 free_d( ptr, DBG_VALUES )
  212.  
  213.    #define _frelocate( ptr )           _frelocate_d( ptr, DBG_VALUES )
  214.  
  215.    #define _hcalloc( nitems, nbytes )  _hcalloc_d( nitems, nbytes, DBG_VALUES )
  216.  
  217.    #define _heappack()                 _heappack_d( DBG_VALUES )
  218.  
  219.    #define _hexpand( ptr, nbytes )     _hexpand_d( ptr, nbytes, DBG_VALUES )
  220.  
  221.    #define _hfree( ptr )               _hfree_d( ptr, DBG_VALUES )
  222.  
  223.    #define _hheappack()                _hheappack_d( DBG_VALUES )
  224.  
  225.    #define _hmalloc( nbytes )          _hmalloc_d( nbytes, DBG_VALUES )
  226.  
  227.    #define _hrealloc( ptr, nbytes )    _hrealloc_d( ptr, nbytes, DBG_VALUES )
  228.  
  229.    #define _hrelocate( ptr )           _hrelocate_d( ptr, DBG_VALUES )
  230.  
  231.    #define malloc( nbytes )            malloc_d( nbytes, DBG_VALUES )
  232.  
  233.    #define _ncalloc( nitems, nbytes )  _ncalloc_d( nitems, nbytes, DBG_VALUES )
  234.  
  235.    #define _nexpand( ptr, nbytes )     _nexpand_d( ptr, nbytes, DBG_VALUES )
  236.  
  237.    #define _nfree( ptr )               _nfree_d( ptr, DBG_VALUES )
  238.  
  239.    #define _nheappack()                _nheappack_d( DBG_VALUES )
  240.  
  241.    #define _nmalloc( nbytes )          _nmalloc_d( nbytes, DBG_VALUES )
  242.  
  243.    #define _nrealloc( ptr, nbytes )    _nrealloc_d( ptr, nbytes, DBG_VALUES )
  244.  
  245.    #define _nrelocate( ptr )           _nrelocate_d( ptr, DBG_VALUES )
  246.  
  247.    #define realloc( ptr, nbytes )      realloc_d( ptr, nbytes, DBG_VALUES )
  248.  
  249.    #define _relocate( ptr )            _relocate_d( ptr, DBG_VALUES )
  250.  
  251. #endif
  252.  
  253. #endif   /* defined( HEAPDBG_H ) */
  254.  
  255.